<template>
    <div>
      <!-- 卡片视图 -->
        <el-card shadow="always">
            <!-- 面包屑导航 -->
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>运营</el-breadcrumb-item>
                <el-breadcrumb-item>客户管理</el-breadcrumb-item>
            </el-breadcrumb>
            <!-- 搜索框 -->
            <el-input style="width:280px;" placeholder="请输入用户姓名" class="search" v-model="searchData" clearable>
                <i slot="prefix" class="el-input__icon el-icon-search"></i>>
                <el-button slot="append" @click="searchBtn" :disabled="isDisabled">搜索</el-button>
            </el-input>
            <!-- 数据列表 -->
            <el-table :data="tableData" border @row-click="ToDetail">
                <el-table-column type="index" label="#" width="75"></el-table-column>
                <el-table-column prop="name" label="姓名"></el-table-column>
                <el-table-column prop="nickname" label="昵称"></el-table-column>
                <el-table-column prop="phone" label="手机号"></el-table-column>
            </el-table>
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="p"
              :page-sizes="[15, 20, 50, 80]"
              :page-size="limit"
              layout="total, sizes, prev, pager, next, jumper"
              :total="count"
            ></el-pagination>
        </el-card>
        <el-dialog title="详情" style="text-align:center" :visible.sync="dialogVisibleAddGroup" width="30%" @submit.native.prevent>
                <div class="veriRevi"> <span>姓名</span><span>{{clickData.name}}</span></div>
                <div class="veriRevi"> <span>昵称</span><span>{{clickData.nickname}}</span></div>
                <div class="veriRevi"> <span>手机号</span><span>{{clickData.phone}}</span></div>
                <div class="veriRevi"> <span>注册时间</span><span>{{clickData.created_at}}</span></div>
                <div class="veriRevi"> <span>是否第一次登录</span><span>{{clickData.first_login==1?'是':'否'}}</span></div>
                <div class="veriRevi"> <span>更新时间</span><span>{{clickData.updated_at}}</span></div>
                <span slot="footer" class="dialog-footer">
                    <el-button @click="dialogVisibleAddGroup=false">确定</el-button>
                </span>
        </el-dialog>
    </div>
</template>

<script>
import {get} from "../../../../public/API/query";
import config from '../../../../public/config'

export default {
    data() {
        return {
            baseUrls:config.get('app_url'),
            //列表数据
            tableData: [
                {name:'张三',photo:'a.png',nickname:'张三',phone:'123456'},
            ],
            //查询参数
            p: 1,
            limit: 10,
            //总条数
            count: null,
            dialogVisible: false,
            currentPage4: 1,
            searchData: "",
            value: [],
            // 树形控件的属性绑定对象
            defaultProps: {
                children: "_child",
                label: "title",
            },
            treeData: [],
            dialogVisibleAddGroup: false,
            addGroupForm: {
                title: "",
            },
            //默认选择节点ID数组
            defaultKeys: [],
            isDisabled: false,
            userId: "",
            clickData:{}
        };
    },
    methods: {
        //设置权限
        setRights(value) {
            
        },
        // 重置节点ID数组
        setRightDialogClose() {
            this.defaultKeys = [];
        },
        //提交权限按钮
        commitRightsBtn() {
           
        },
        //获取数据
        getTableData(){
            if (this.searchData) {
                get('operate/client/index',{
                    p:this.p,
                    limit:this.limit,
                    title:this.searchData
                },res=>{
                    this.tableData = res.data._list
                    this.count = res.data.count
                })
            }else{
                get('operate/client/index',{
                    p:this.p,
                    limit:this.limit,
                },res=>{
                    this.tableData = res.data._list
                    this.count = res.data.count
                })
            }
        },
        handleSizeChange(newSize) {
            this.limit = newSize;
            this.getTableData();
        },
        handleCurrentChange(newPage) {
            this.p = newPage;
            this.getTableData();
        },
        //添加用户组
        openAddGroupDialog() {
        },
        //添加用户组
        addGroup() {
            
        },
        //启用按钮
        enableBtn(value) {
            
        },
        //禁用按钮
        disableBtn(value) {
          
        },
        //搜索功能
        searchBtn() {
            this.getTableData()
        },
        //跳转到详情页
        ToDetail(value){
            get('operate/client/detail',{id:value.id},res=>{
                this.clickData = res.data.info
                this.dialogVisibleAddGroup = true
            })
            
        }
    },
    watch: {
        searchData: function() {
            if (!this.searchData) {
                this.getTableData();
            }
            if (this.searchData) {
                this.isDisabled = false;
            }
        }
    },

    created() {
        this.getTableData();
    },
};
</script>

<style lang="less" scoped>
.veriRevi{
    width: 100%;
    margin-top: 10px;
    span:nth-child(1){
        width: 50%;
        text-align: left;
    }
    span:nth-child(2){
        width: 50%;
        text-align: right;
    }
    &:last-of-type{
        margin-bottom: 20px;
    }
}
.el-breadcrumb {
    margin-bottom: 30px;
}
.el-input {
    margin-bottom: 30px;
    width: 280px;
    margin-right: 30px;
}
.el-pagination {
    margin-top: 30px;
}
.addRulesWrap {
    margin-left: 80px;
}
.addRules {
    position: absolute;
    right: 25%;
    bottom: 5%;
}
.disable {
    margin-left: 15px;
}
</style>
